function pal(p:longint;c:string):string;
var
  i:longint;
  s:string;
begin
  s:='';
  if p mod 9<>0 then s:=s+chr(ord('0')+ p mod 9);
  for i:=1 to p div 9 do s:=s+'9';
  s:=s+c;
  for i:=1 to p div 9 do s:=s+'9';
  if p mod 9<>0 then s:=s+chr(ord('0')+ p mod 9);
  result:=s;
end;

var
  s:longint;
  c1,c2:string;
begin
  readln(s);
  if s<10 then writeln(s)
  else
    if s mod 2 <> 0 then writeln(pal((s-9) div 2,'9'))
    else
      begin
         c1:=pal((s-8) div 2,'8');
         c2:=pal(s div 2,'');
         if length(c1)<length(c2) then writeln(c1) else writeln(c2);
      end;
end.